#include "imagemodel.h"


ImageModel::ImageModel(QObject *parent)
    :QAbstractListModel(parent)
{
    m_contentImageItems.clear();
}


int ImageModel::rowCount(const QModelIndex & parent) const {
    Q_UNUSED(parent);
    return m_contentImageItems.count();
}

QVariant ImageModel::data(const QModelIndex & index, int role) const {
    if (index.row() < 0 || index.row() >= m_contentImageItems.count())
        return QVariant();

    const TextData textData = m_contentImageItems[index.row()];

    if (role == ImageRole)
        return textData.data();

    return QVariant();
}

QHash<int, QByteArray> ImageModel::roleNames() const {
    QHash<int, QByteArray> roles;
    roles[ImageRole] = "contentImageRow";
    return roles;
}

void ImageModel::setContentImageArticle(const QList<TextData>& _contentImageItems)
{
    beginResetModel();
    m_contentImageItems = _contentImageItems;
    endResetModel();
}
